<script type="text/javascript">
	jQuery(document).ready(function($) { 
		$("form#comment-form").submit(function(){
			var proid = $('#cproid').attr('value');
			var name = $('#cname').attr('value');
			var email = $('#cemail').attr('value');
			var content = $('#txtComment').attr('value');
			var datastring = 'proid=' + proid + '&name=' + name + '&email=' + email + '&content=' + content;
			if(name=='' || email=='' || content=='')
			{
				alert('Please Give Valid Details');
			}
			else
			{
				$("#flash").show();
				$("#flash").fadeIn(400).html('<img src="ajax-loader.gif" />Loading Comment...');
			}
			$.ajax({
				type: "POST",
				url: 'templates/comment_process.php',
				data: datastring,
				success:  function(html){
					$("div#update").append(html);
					$("div#update li:last").fadeIn("slow");
					document.getElementById('cemail').value='';
					document.getElementById('cname').value='';
					document.getElementById('txtComment').value='';
					$("#cname").focus();
  					$("#flash").hide();
				}
			});
			return false;
		});
	});
</script>

<div style="margin-bottom:20px; border-bottom:#dedede dashed 1px;">
	<?php 
		$sqldate = strtotime($pro_date_added);
		$postdate = date('H \g\i\ờ\ m \p\h\ú\t\ \n\g\à\y\ d \t\h\á\n\g\ m \n\ă\m\ Y', $sqldate);
		echo "<font style=' font-style:italic;'> Đăng vào lúc $postdate</font>"; 
	?>
</div>
<div style="margin-top:20px; margin-left:100px; width:70%;">
	
    <div id="update" class="timeline">
	<?php 
		$id = $_GET['id'];
		$sql = "SELECT * FROM tbl_comment WHERE id_product = '$id' ORDER BY id DESC";
		$result1 = mysql_query("$sql");
		if(mysql_num_rows($result1)>0)
		{
			while($comment_rows = mysql_fetch_assoc($result1))
			{
				extract($comment_rows);
	?>
	<div class="box">
		<img id="<?php echo "comment-$id";?>" src="http://www.gravatar.com/avatar.php?gravatar_id=" style="float:left; width:60px; height:60px; margin-right:20px"/>
        <span style="font-size:16px; color:#663399; font-weight:bold"> <?php echo $name;?></span> <br /><br />
		<?php echo $comment_content; ?>
	</div>
     <?php
			}
		}
	?>
 
 </div>
</div>
<div id="flash"></div>
<div style="margin-left:100px">

<form id="comment-form" method="post" style="margin-top:50px;">
	<input type="hidden" id="cproid" value="<?php 
	$page = _getCurrentPageURL();
	echo substr(strstr($page, 'id='),3); 
	?>" />
	<p>
	<label>Name</label>
    <input id="cname" type="text"  style="width:280px"/>
    </p>
    <p>
    <label>Email</label>
    <input id="cemail" type="text"  style="width:280px"/>
    </p>
    <p>
    	<textarea id="txtComment" style="width:350px; height:200px" ></textarea>
    </p>
    <button type="submit">Submit</button>
</form>
</div>